<%--
  Created by IntelliJ IDEA.
  User: HP
  Date: 2021-09-16
  Time: 19:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<div class="col-md-9">


    <div class="data_list">
        <div class="data_list_title">
            <span class="glyphicon glyphicon-cloud-upload"></span>&nbsp;
          <c:if test="${empty noteInfo}">
                发布云记
            </c:if>
            <c:if test="${!empty noteInfo}">
                修改云记
            </c:if>




        </div>
        <div class="container-fluid">
            <div class="container-fluid">
                <div class="row" style="padding-top: 20px;">
                    <div class="col-md-12">
                 <c:if test="${empty typeList}">
       <h2>未查询到云记类型，请先添加</h2>
       <h4><a href="type?actionName=query">添加类型</a> </h4>

                   </c:if>
                        <c:if test="${!empty typeList}">
                        <form class="form-horizontal" method="post" action="modify">
                            <input type="hidden" name="actionName" value="addOrUpdate"/>
                            <input type="hidden" name="noteId" value="${noteInfo.noteId}"/>
                            <input type="hidden" name="lon" id="lon">
                            <input type="hidden" name="lat" id="lat">


                            <div class="form-group">
                                <label for="type" class="col-sm-2 control-label">类别:</label>
                                <div class="col-sm-6">
                                    <select id="type" class="form-control" name="typeId">
                                        <option value="-1">请选择云记类别...</option>
                                         <c:forEach var="item" items="${typeList}">


                                        <option   <c:if test="${noteInfo.typeId ==item.typeId}">selected</c:if>              value="${item.typeId}"> ${item.typeName} </option>

                                         </c:forEach>


                                    </select>
                                </div>
                            </div>
                            <div class="form-group">

                                <label for="title" class="col-sm-2 control-label">标题:</label>
                                <div class="col-sm-6">
                                    <input class="form-control" name="title" id="title" placeholder="云记标题" value="${noteInfo.title}">
                                </div>
                            </div>

                            <div class="form-group">

                                <label for="title" class="col-sm-2 control-label">内容:</label>
                                <div class="col-sm-8">
                                  <textarea id="content" name="content">
                                  ${noteInfo.content}
                                  </textarea>

                                </div>

                            </div>
                            <div class="form-group">
                                <div class="col-sm-offset-6 col-sm-4">
                                    <input type="submit" class="btn btn-primary" onclick="return checkForm()" value="保存">
                                    &nbsp;<span id="msg" style="font-size:12px;color:red"></span>
                                </div>
                            </div>
                        </form>
                        </c:if>


                    </div>
                </div>
            </div>
        </div>
    </div>


</div>
<script type="text/javascript">

    var ue;
   $(function (){
        ue=UE.getEditor('content');
   });

   function  checkForm(){

       var typeId =$("#type option:selected").val();
       var title = $("#title").val();
       var content=ue.getContent();
       if(typeId=="-1"){
          $("#msg").html("请选择云记类型！")
          return false;
       }
       if(isEmpty(title)){
           $("#msg").html("云记标题不能为空！")
           return false;
       }
       if(isEmpty(content)){
           $("#msg").html("云记内容不能为空！")
           return false;
       }



       return true;
   }


</script>

<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=4y2vBPQFwQ6j67gqN4Cm0AMkGacEr7Iu"></script>
<script type="text/javascript">
    var geolocation=new BMap.Geolocation();
    geolocation.getCurrentPosition(function (r){
        if(this.getStatus()==BMAP_STATUS_SUCCESS){
            console.log("location:"+r.point.lng+","+r.point.lat);
        $("#lon").val(r.point.lng);
            $("#lat").val(r.point.lat);
        }else{
            console.log("failed:"+this.getStatus());
        }

        }
    );




</script>